package com.example.demospringboot.netty.custom.handler;

import com.example.demospringboot.netty.custom.procotol.ComPack;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author chenlei
 * @date 2020/1/17
 * @description
 **/
public class ServerChannelHandler extends SimpleChannelInboundHandler<ComPack> {

    private Logger log = LoggerFactory.getLogger(getClass());

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, ComPack comPack) throws Exception {
        log.info("接收到客户端的消息" + comPack.getId() + "，message:" + comPack.getMessage());
        ctx.writeAndFlush(comPack);
    }
}
